Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: use shared informers to watch resource #615

Merged
merged 7 commits into from
Jun 7, 2024

Conversation

adityathebe
Copy link
Member

No description provided.

@adityathebe adityathebe force-pushed the feat/use-shared-informers-to-watch-resources branch from 1e053b1 to d45e1a2 Compare June 5, 2024 05:26
@adityathebe adityathebe marked this pull request as ready for review June 5, 2024 05:27
utils/kube/kube.go Outdated Show resolved Hide resolved
@@ -38,6 +40,18 @@ import (
"k8s.io/client-go/util/homedir"
)

var kubeClientCreatedCount = prometheus.NewCounterVec(
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should this be a ctx.Counter() ?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

kube client creation is called in a bunch of places and they don't pass in the context. So I did it this way.

@adityathebe adityathebe force-pushed the feat/use-shared-informers-to-watch-resources branch 2 times, most recently from 9f05144 to 76fa84c Compare June 7, 2024 02:59
)

// WatchResources watches Kubernetes resources
func getUnstructuredFromInformedObj(resource v1.KubernetesResourceToWatch, obj any) (*unstructured.Unstructured, error) {
b, err := json.Marshal(obj)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do we need to marshal and unmarshall - It should be unstructured already ?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, we receive concrete types like core v1.Pod

}
}

factory := informers.NewSharedInformerFactory(ctx.Kubernetes(), 0)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this already prepopulated with kubeconfigs client ?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ya we set it here

func applyKubeconfig(ctx api.ScrapeContext, kubeConfig types.EnvVar) (api.ScrapeContext, *rest.Config, error) {

@adityathebe adityathebe force-pushed the feat/use-shared-informers-to-watch-resources branch from 76fa84c to 8c65ceb Compare June 7, 2024 10:51
@moshloop moshloop merged commit da60bef into main Jun 7, 2024
7 checks passed
@moshloop moshloop deleted the feat/use-shared-informers-to-watch-resources branch June 7, 2024 11:34
Copy link

🎉 This PR is included in version 0.0.318 🎉

The release is available on GitHub release

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants